import { defineBoot } from '#q-app/wrappers';
import Dexie from 'dexie';
import { serializer } from 'src/common/utils';
import defaultAvatar from 'src/assets/sharpicons_Fish.png';
let example = {
  children: [
    {
      name: 'SeparatorComponent',
      layout: {
        zIndex: 1,
        width: 793,
        height: 15,
        rotate: 0,
        x: 0,
        y: 139,
      },
      model: {
        color: '#0d6fd1',
        size: 2,
        vertical: false,
      },
      type: 'node',
      label: '分隔线',
      icon: '线',
      id: '85feff3c-343d-4bba-9340-12010ad748f4',
      lock: false,
      rotate: true,
      index: 0,
      parentId: 'example',
    },
    {
      name: 'AvatarComponent',
      icon: '头',
      label: '头像',
      group: 'node',
      type: 'node',
      model: {
        avatarUrl: defaultAvatar,
        avatarStyle: 'rounded',
      },
      layout: {
        zIndex: 1,
        width: 100,
        height: 100,
        rotate: 0,
        initWidth: 100,
        initHeight: 100,
        resize: true,
        x: 674,
        y: 20,
      },
      id: '4ba0a2e3-c176-40a2-aafb-064e762d38fe',
      lock: false,
      rotate: true,
      index: 1,
      parentId: 'example',
    },
    {
      name: 'TimeLine',
      icon: '时',
      label: '时间线',
      group: 'node',
      type: 'node',
      layout: {
        zIndex: 1,
        width: 794,
        height: 619,
        rotate: 0,
        x: 0,
        y: 853,
      },
      model: {
        layout: 'dense',
        side: 'right',
        color: 'primary',
        icon: 'done_all',
        timeline: [
          {
            title: 'xxx项目',
            subtitle: '2024-01-01~2024-01-05',
            content: '内容',
            contentStyle: 'default',
            id: 'f8cb8883-2f29-4c08-a4db-42e84bac646a',
          },
          {
            title: 'xxx项目',
            subtitle: '2025-01-01~至今',
            content: '内容',
            id: '1',
            side: 'right',
          },
        ],
        contentStyle: 'default',
      },
      id: 'a6d29820-b751-4275-afe6-d1ef7454569c',
      lock: false,
      rotate: true,
      index: 2,
      parentId: 'example',
    },
    {
      children: [
        {
          name: 'TextComponent',
          layout: {
            zIndex: 2,
            width: 200,
            height: 20,
            rotate: 0,
            x: 20,
            y: 167,
          },
          model: {
            color: '#ffffff',
            fontSize: 16,
            text: '工作经历',
          },
          type: 'node',
          label: '工作经历',
          icon: '文',
          id: '82433781-02d6-436d-83b6-db6a06ffe5dd',
          lock: false,
          rotate: true,
          index: 3,
        },
        {
          name: 'RectangleComponent',
          layout: {
            zIndex: 1,
            width: 150,
            height: 30,
            rotate: 0,
            x: 0,
            y: 162,
          },
          model: {
            backgroundColor: '#0d6fd1',
            borderWidth: 1,
            borderColor: '#0d6fd1',
            borderRadius: 0,
          },
          type: 'node',
          label: '矩形',
          icon: '矩',
          id: '4bf07205-ee98-4860-ac48-ea0dc140e5df',
          lock: false,
          rotate: true,
          index: 3,
        },
      ],
      name: 'GroupComponent',
      label: '组1',
      id: 'f4261dd0-e96d-4f25-9cc3-c260d257cb31',
      layout: {
        x: 0,
        y: 162,
        width: 220,
        height: 30,
        zIndex: 3,
      },
      type: 'group',
      parentId: 'example',
      index: 3,
      lock: false,
      rotate: false,
    },
    {
      children: [
        {
          name: 'TextComponent',
          layout: {
            zIndex: 2,
            width: 200,
            height: 20,
            rotate: 0,
            x: 20,
            y: 25,
          },
          model: {
            color: '#ffffff',
            fontSize: 16,
            text: '个人信息',
          },
          type: 'node',
          label: '个人信息',
          icon: '文',
          id: '88a49b2b-7f51-4e3d-b169-3663c18a3d10',
          lock: false,
          rotate: true,
          index: 3,
          parentId: 'eec4bb60-757d-4ee3-8a10-b0b947f4249a',
        },
        {
          name: 'RectangleComponent',
          layout: {
            zIndex: 1,
            width: 150,
            height: 30,
            rotate: 0,
            x: 0,
            y: 20,
          },
          model: {
            backgroundColor: '#0d6fd1',
            borderWidth: 1,
            borderColor: '#0d6fd1',
            borderRadius: 0,
          },
          type: 'node',
          label: '复制-矩形',
          icon: '矩',
          id: '7d18aa25-0860-4920-a2b4-891514425329',
          lock: false,
          rotate: true,
          index: 3,
          parentId: 'eec4bb60-757d-4ee3-8a10-b0b947f4249a',
        },
      ],
      name: 'GroupComponent',
      label: '复制-组1',
      id: 'eec4bb60-757d-4ee3-8a10-b0b947f4249a',
      layout: {
        x: 0,
        y: 20,
        width: 220,
        height: 30,
        zIndex: 3,
      },
      type: 'group',
      parentId: 'example',
      index: 4,
      lock: false,
      rotate: false,
    },
    {
      children: [
        {
          name: 'TextComponent',
          layout: {
            zIndex: 2,
            width: 200,
            height: 20,
            rotate: 0,
            x: 20,
            y: 828,
          },
          model: {
            color: '#ffffff',
            fontSize: 16,
            text: '项目经历',
          },
          type: 'node',
          label: '复制-工作经历',
          icon: '文',
          id: 'c3a430a9-5fef-4d86-a150-a82be09dc9f6',
          lock: false,
          rotate: true,
          index: 3,
          parentId: '2d49fcd7-98a4-4a6e-8684-7216c85a22ba',
        },
        {
          name: 'RectangleComponent',
          layout: {
            zIndex: 1,
            width: 150,
            height: 30,
            rotate: 0,
            x: 0,
            y: 823,
          },
          model: {
            backgroundColor: '#0d6fd1',
            borderWidth: 1,
            borderColor: '#0d6fd1',
            borderRadius: 0,
          },
          type: 'node',
          label: '复制-矩形',
          icon: '矩',
          id: 'c10cdc89-bb07-4a1a-91f2-b8adbda260b1',
          lock: false,
          rotate: true,
          index: 3,
          parentId: '2d49fcd7-98a4-4a6e-8684-7216c85a22ba',
        },
      ],
      name: 'GroupComponent',
      label: '复制-组1',
      id: '2d49fcd7-98a4-4a6e-8684-7216c85a22ba',
      layout: {
        x: 0,
        y: 823,
        width: 220,
        height: 30,
        zIndex: 3,
      },
      type: 'group',
      parentId: 'example',
      index: 5,
      lock: false,
      rotate: false,
    },
    {
      name: 'TextComponent',
      layout: {
        zIndex: 1,
        width: 118,
        height: 23,
        rotate: 0,
        x: 20,
        y: 55,
      },
      model: {
        color: '#333333',
        fontSize: 16,
        text: '姓名：Salt Fish',
      },
      type: 'node',
      label: '纯文本',
      icon: '文',
      id: 'a57761a5-90ef-4c91-827a-305edcf401a3',
      lock: false,
      rotate: true,
      index: 6,
      parentId: 'example',
    },
    {
      name: 'TextComponent',
      layout: {
        zIndex: 1,
        width: 202,
        height: 23,
        rotate: 0,
        x: 20,
        y: 83,
      },
      model: {
        color: '#333333',
        fontSize: 16,
        text: '求职岗位：前端开发工程师',
      },
      type: 'node',
      label: '复制-纯文本',
      icon: '文',
      id: '256baaf2-8cc1-459a-9b6d-c8c094357040',
      lock: false,
      rotate: true,
      index: 7,
      parentId: 'example',
    },
    {
      name: 'TextComponent',
      layout: {
        zIndex: 1,
        width: 442,
        height: 23,
        rotate: 0,
        x: 20,
        y: 111,
      },
      model: {
        color: '#333333',
        fontSize: 16,
        text: '联系方式：https://gitee.com/salted-fish-333/resume-creation',
      },
      type: 'node',
      label: '复制-复制-纯文本',
      icon: '文',
      id: '580690a9-bee1-4ce3-9030-4db5b1a483cf',
      lock: false,
      rotate: true,
      index: 8,
      parentId: 'example',
    },
    {
      name: 'TextComponent',
      layout: {
        zIndex: 1,
        width: 78,
        height: 23,
        rotate: 0,
        x: 150,
        y: 55,
      },
      model: {
        color: '#333333',
        fontSize: 16,
        text: '性别：男',
      },
      type: 'node',
      label: '复制-纯文本',
      icon: '文',
      id: 'f0ebb857-03d1-45bd-956d-bea0c054a6be',
      lock: false,
      rotate: true,
      index: 9,
      parentId: 'example',
    },
    {
      name: 'TextComponent',
      layout: {
        zIndex: 1,
        width: 139,
        height: 23,
        rotate: 0,
        x: 243,
        y: 55,
      },
      model: {
        color: '#333333',
        fontSize: 16,
        text: '毕业院校：xx大学',
      },
      type: 'node',
      label: '复制-复制-纯文本',
      icon: '文',
      id: 'ce01b5a7-f866-4662-b7f6-ea6595c3733e',
      lock: false,
      rotate: true,
      index: 10,
      parentId: 'example',
    },
    {
      name: 'TimeLine',
      icon: '时',
      label: '复制-时间线',
      group: 'node',
      type: 'node',
      layout: {
        zIndex: 1,
        width: 794,
        height: 619,
        rotate: 0,
        x: 0,
        y: 192,
      },
      model: {
        layout: 'dense',
        side: 'right',
        color: 'primary',
        icon: 'done_all',
        timeline: [
          {
            title: 'xxx公司',
            subtitle: '2024-01-01~2024-01-05',
            content: '内容',
            contentStyle: 'default',
            id: 'f8cb8883-2f29-4c08-a4db-42e84bac646a',
          },
          {
            title: 'xxx公司',
            subtitle: '2025-01-01~至今',
            content: '内容',
            id: '1',
            side: 'right',
          },
        ],
        contentStyle: 'default',
      },
      id: '958a1136-05ab-4025-9363-c1acfae04537',
      lock: false,
      rotate: true,
      index: 11,
      parentId: 'example',
    },
  ],
  id: 'example',
  name: 'root',
  label: '示例',
  layout: {
    height: 2246,
    width: 794,
    padding: 0,
    x: 0,
    y: 0,
  },
  scope: false,
  createTime: 1738828918138,
  updateTime: 1738912770075,
  lock: false,
};
export default defineBoot(() => {
  // 创建数据库实例
  // console.log('indexedDB', Dexie);
  window.DB = new Dexie('resumeDB');
  window.DB.version(1).stores({
    resume: '++dbId,id,label',
  });
  window.DB.on('populate', () => {
    console.log('数据库初始化完成');
    example.children = serializer.serialize(example.children);
    window.DB.resume.add(example);
  });
});
